import { is } from "@electron-toolkit/utils";
import { BrowserWindow } from "electron";
import url from "node:url";

import { join } from "path";

class FontSettingsWindow {
    windowInstance = {} as BrowserWindow;
    constructor() {
        this.windowInstance = new BrowserWindow({
            width: 400,
            height: 500,
            title: "字体",
            minimizable: false,
            maximizable: false,
            show: false,
            frame: true,
            resizable: false,
            hasShadow: false,
            autoHideMenuBar: true,
            webPreferences: {
                preload: join(__dirname, "../preload/index.js"),
                sandbox: false,
            },
        });

        if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
            this.windowInstance.loadURL(
                process.env["ELECTRON_RENDERER_URL"] + "/#/font"
            );
        } else {
            this.windowInstance.loadURL(
                url.format({
                    pathname: join(__dirname, "../renderer/index.html"),
                    protocol: "file:",
                    slashes: true,
                    hash: "font",
                })
            );
        }
    }
}

export default FontSettingsWindow;
